package com.touchealth.test.meinian;

import lombok.Getter;

/**
 * @author zhengyang
 * @date 2020-12-22 16:47
 */
public interface MeinianEnum {
    @Getter
    enum Sex{

        MAN(1, "男"),
        WUMAN(2, "女");

        private Integer code;
        private String name;

        Sex(Integer code, String name){
            this.code = code;
            this.name = name;
        }

        public static Integer toCode(String name) {
            for (Sex v : Sex.values()) {
                if (v.name.equals(name)) {
                    return v.code;
                }
            }

            return null;
        }

        public static String toName(Integer code) {
            for (Sex v : Sex.values()) {
                if (v.code.equals(code)) {
                    return v.name;
                }
            }

            return null;
        }
    }

    @Getter
    enum Marry{
        MARRIED(1, "已婚"),
        UMMARRIED(2, "未婚");

        private Integer code;
        private String name;

        Marry(Integer code, String name){
            this.code = code;
            this.name = name;
        }

        public static Integer toCode(String name) {
            for (Marry v : Marry.values()) {
                if (v.name.equals(name)) {
                    return v.code;
                }
            }

            return null;
        }

        public static String toName(Integer code) {
            for (Marry v : Marry.values()) {
                if (v.code.equals(code)) {
                    return v.name;
                }
            }

            return null;
        }
    }
}
